package com.beiding.dao;

import com.beiding.pojo.local.LocalRoom;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.solr.core.query.result.HighlightPage;
import org.springframework.data.solr.repository.Highlight;
import org.springframework.data.solr.repository.Query;
import org.springframework.data.solr.repository.SolrCrudRepository;

public interface LocalRoomSearchDao extends SolrCrudRepository<LocalRoom, String> {

    @Highlight(prefix = "<b>", postfix = "</b>")
    @Query(value = "(name:?0 OR location_address:?0 OR location_detailedDescription:?0) AND holderId:\"?1\"")
    HighlightPage<LocalRoom> find(String q, String holderId, Pageable page);

    @Query(value = "holderId:\"?0\"")
    Page<LocalRoom> findByHolderId(String holderId, Pageable page);


    //solr的exists判断存在问题,会出现无法将Room强转为Boolean的问题
    @Query(fields = {"id"})
    LocalRoom findByHolderIdAndId(String holderId, String id);


}
